package com.ojoin.trade.supplyloan_core.web.service.impl;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.web.dao.BaseDao;
import com.ojoin.trade.common.web.service.impl.BaseServiceImpl;
import com.ojoin.trade.supplyloan_core.web.dao.TbSlCreditControllDao;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlCreditControll;
import com.ojoin.trade.supplyloan_core.web.service.TbSlCreditCtrollService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 16-4-11
 * Time: 下午3:46
 * To change this template use File | Settings | File Templates.
 */
@Service
public class TbSlCreditCtrollServiceImpl extends BaseServiceImpl<TbSlCreditControll> implements TbSlCreditCtrollService {

    @Autowired
    private TbSlCreditControllDao dao;
    @Override
    protected BaseDao<TbSlCreditControll> getBaseDao() {
        return dao;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void update(Map<String, Object> map) throws BusinessException {
        ((TbSlCreditControllDao)getBaseDao()).update(map);
    }

    @Override
    public TbSlCreditControll queryTbSlCreditControll(Integer id_of_merchant) throws BusinessException {
        return   ((TbSlCreditControllDao)getBaseDao()).queryTbSlCreditControll(id_of_merchant);
    }

    @Override
    public void lockById(int id) throws BusinessException {
        ((TbSlCreditControllDao)getBaseDao()).lockById(id);
    }

    @Override
    public void insertControllVo(Integer joinid) throws BusinessException {
        TbSlCreditControll vo=queryTbSlCreditControll(joinid);
        if(vo==null){
            TbSlCreditControll controllvo=new TbSlCreditControll();
            controllvo.setIdOfMerchant(joinid);
            controllvo.setAmount("0");
            insert(controllvo);
        }
    }
}
